var http = require('http');
http.createServer(function (request, response) {
    // 渲染页面
//   response.writeHead(200, {'Content-Type': 'text/html;charset=utf-8'});
    const str =`<!DOCTYPE html>
                        <html lang="zh-CN">
                        <head>
                            <meta charset="UTF-8">
                            <meta http-equiv="X-UA-Compatible" content="IE=edge">
                            <meta name="viewport" content="width=device-width, initial-scale=1.0">
                            <title>Document</title>
                            <style>
                                div{
                                    width: 100px;
                                    height: 100px;
                                    background-color: red;
                                }
                            </style>
                        </head>
                        <body>
                            <div></div>
                        </body>
                        </html>`
    
    // 渲染json数据
    response.writeHead(200, { 'Content-Type': 'application/json' });
    const obj = [
        {
            name: zhangsan,
            id:0
        },
        {
            name: lisi,
            id: 1
        },
        {
            name: wangwu,
            id: 2
        }
    ]
    // response.end(str)
    response.end(obj)
}).listen(8082);

console.log('Server running at http://127.0.0.1:8082/');